<template>
  <div class="page">
    <van-nav-bar title="微信支付" @click-left="$router.go(-1)">
      <div slot="left">
        <van-icon name="wap-home-o" class="f20" />
      </div>
    </van-nav-bar>
    <div class="flex jc-c bg-fff">
      <img :src="queryObj.ewm" />
    </div>
    <p class="f30 bg-fff tac pt-15 pb-15">
      ￥{{ (queryObj.allFee * 1).toFixed(2) }}
    </p>
    <van-cell-group>
      <van-cell title="订单编号" value="" />
      <van-cell title="收款方" value="天堂电子商务有限公司" />
      <van-cell title="剩余支付时间">
        <van-count-down :time="time" />
      </van-cell>
    </van-cell-group>
  </div>
</template>




<script>
export default {
  data() {
    return {
      //从确认订单页面传过来的参数
      queryObj: this.$route.query,
      //定时器
      timer: null,
    };
  },
  created() {
    this.getOrderDetail();
  },
  beforeDestroy() {
    console.log("销毁");
    clearInterval(this.timer);
  },
  computed: {
    time() {
      return 15 * 60 * 1000 - (Date.now() - this.queryObj.createTime);
    },
  },
  methods: {
    //轮巡订单详情接口,查看订单状态
    getOrderDetail() {
      this.timer = setInterval(async () => {
        let res = await this.$axios.post("/order/detail", {
          orderId: this.queryObj.orderId,
        });
        console.log("订单状态", res.result.orderStatus);
        let { orderStatus } = res.result;
        if (orderStatus === "01") {
          console.log("跳转");
        }
      }, 2000);
    },
  },
};
</script>
